package fei.zhou.springboot4.business.config.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * 描述该类- JPA
 *
 * @author zhoufei
 * @class: MyFilter
 * @date 2021/1/20 10:44
 * @Verson 1.0 -2021/1/20 10:44
 * @see
 */
public class MyFilter implements Filter {
    
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        
        HttpServletRequest hsr = (HttpServletRequest) request;
        String url = hsr.getRequestURL().toString();
        
        // 不拦截
        if (url.contains("/todoMyServlet")) {
            System.out.println("执行后面的代码,对应的url:" + url);
            chain.doFilter(request, response);
        }
        
        if (url.contains("/test")) {
            System.out.println("拦截不让执行后面的代码,对应的url:" + url);
            return;
        }
        
    }
    
}
